/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.sql.Date;

/**
 *
 * @author JArik
 */
public class Drug extends Item {
    private boolean deleted=false;
    //private Sklad sklad;

    public Drug()
    {
        super();
    }
    public Drug(int aInt, String string) {
        //sellPrices = new double[3];
        super();
        super.setId(aInt);
        super.setName(string);
    }
    public Drug(int newId, int newDist, String newName, Date newInDate)
    {
        //sellPrices = new double[3];
        super();
        super.setId(newId);
        super.setName(newName);
        super.setDisID(newDist);
        super.setInDate(newInDate);
        super.setDisDate(null);
    }
    public Drug(int newId, int newDist, String newName, Date newInDate, Date disDate)
    {
        //sellPrices = new double[3];
        super();
        super.setId(newId);
        super.setName(newName);
        super.setDisID(newDist);
        super.setInDate(newInDate);
        super.setDisDate(disDate);
        
    }
    public Drug(int newId, int newDist, String newName, Date newInDate, Date disDate, Doctor nDoctor)
    {
        //sellPrices = new double[3];
        super();
        super.setId(newId);
        super.setName(newName);
        super.setDisID(newDist);
        super.setInDate(newInDate);
        super.setDisDate(disDate);
        super.setDoctor(nDoctor);
    }
    public Drug(int newId, int newDist, String newName, Date newInDate, Visit nVisit)
    {
        //sellPrices = new double[3];
        super();
        super.setId(newId);
        super.setName(newName);
        super.setDisID(newDist);
        super.setInDate(newInDate);
        super.setDisDate(nVisit.getDisDate());
        super.setDoctor(nVisit.getExec());
    }

    public void setDeleted(boolean del)
    {
        deleted = del;
    }
    public boolean isDeleted()
    {
        return deleted;
    }

    public String toTableString()
    {
        if(this.getDisDate() != null)
            return (this.getName() ==null ? "Лекарство без названия":getName());
        else 
            return getNaming();
    }
    public String getNaming() {
        if(this.getName() == null)
                return "Лекарство без названия";
            else if(getType() == null || getType().equals(""))
                return this.getName();
            else
                return ""+getType()+" "+this.getName();
    }
    public String toString()
    {
        if(this.getDisDate() != null)
            return (this.getName()==null ? "Лекарство без названия":getName());
        else if(this.getRecId() == 0)
            return getNaming();
        else // so sklada
            return "<html>Партия No. " + this.getRecId() +
                    " ||| Склад "+ getSklad().getName() +
                                           " ||| Дата ("
                                           +(this.getInDate() == null ? "Неизвестно":this.getInDate().toString())+
                                           ") Кол-во="+getAmount()+
                                           "</html>";
    }

}
